﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QxFramework.Core;
using GameMap;
using GameControl;
public class CollectableItemInteraction :Interaction
{
    public override void Start()
    {
        base.Start();
        this.transform.Find("Sprite").GetComponent<SpriteRenderer>().sprite = null;
    }
   /* private void Update()
    {
        if(this.transform.Find("Sprite").GetComponent<SpriteRenderer>().sprite == null && GameManager.Get<IItemInstantiateManager>() != null)
        {
            this.transform.Find("Sprite").GetComponent<SpriteRenderer>().sprite = GameManager.Get<IItemInstantiateManager>().GetItemSettingByName((GetComponent<CollectableItem>().ItemFieldSetting as CollectableItemField).CanCollectItemName).transform.Find("Sprite").GetComponent<SpriteRenderer>().sprite;

        }
    }*/
    public override void Invoke(CombinableItemField info)
    {
        base.Invoke(info);
        MessageManager.Instance.Get<ItemMapEvent>().DispatchMessage(ItemMapEvent.ToBag, this, new ItemMapArgs
        {
            User = info.User,
            ItemName = GameControl.GameManager.Get<GameControl.IItemInstantiateManager>().CreatItemField((GetComponent<CollectableItem>().ItemFieldSetting as CollectableItemField).CanCollectItemName).ItemName
        }) ;
        MessageManager.Instance.Get<ItemMapEvent>().DispatchMessage(ItemMapEvent.DeleteInMap, this, new ItemMapArgs
        {
            //UserName = this.Tag,
            ItemName = this.gameObject.name
        }) ;
    }
}
